Skip to content

Improve flip negative ternary sniff#2856

Merged
Crabcyborg merged 1 commit into
masterfrom
improve_flip_negative_ternary_sniff
Jan 21, 2026
Merged

Improve flip negative ternary sniff#2856
Crabcyborg merged 1 commit into
masterfrom
improve_flip_negative_ternary_sniff

Conversation

@Crabcyborg

@Crabcyborg Crabcyborg commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Refactor
    • Improved code style consistency in form entry handling
    • Enhanced code quality checks for ternary operator detection to cover broader negation patterns

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 21, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Two files are modified: a stylistic simplification of a ternary conditional in FrmEntry.php, and a refactoring of the FlipNegativeTernarySniff to generalize its negation detection logic from function-specific to handle broader conditions including negated variables.

Changes

Cohort / File(s) Summary
Stylistic ternary simplification
classes/models/FrmEntry.php
Flipped conditional from negated to direct check in insert_entry_into_database: ! $query_results ? false : $wpdb->insert_id$query_results ? $wpdb->insert_id : false. Behavior unchanged.
Generalized negation detection
phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/FlipNegativeTernarySniff.php
Refactored sniff to detect negated conditions broadly (both negated function calls and negated variables). Renamed methods: findNegatedFunctionCall()findNegatedCondition(), processNegatedFunctionCall()processNegatedCondition(). Updated return keys 'function'/'function_end''condition'/'condition_end'. Diagnostic code changed from NegatedFunctionTernary to NegatedTernary. Extended logic to validate simple negated variables with additional token checks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A ternary flips with graceful ease,
From not to yes, just as you please!
The sniff now sees beyond function calls,
Negations everywhere answer its calls.
Cleaner code hops through the review hall! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Improve flip negative ternary sniff' accurately summarizes the main change: expanding the FlipNegativeTernarySniff to handle negated variables in addition to negated function calls.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Crabcyborg
Crabcyborg merged commit 3340f1a into master Jan 21, 2026
35 of 38 checks passed
@Crabcyborg
Crabcyborg deleted the improve_flip_negative_ternary_sniff branch January 21, 2026 21:05
stephywells pushed a commit that referenced this pull request Apr 4, 2026
…y_sniff

Improve flip negative ternary sniff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant